<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::connection('mysql_log')->create('log_user_role_login', function (Blueprint $table) {
            $table->engine  = 'InnoDB';
            $table->comment('sdk角色登录日志');

            $table->increments('id');
            $table->integer('create_time')->comment('创建时间')->unsigned()->default(0);
            $table->integer('game_id')->comment('游戏id')->unsigned()->default(0);
            $table->integer('channel')->comment('渠道ID')->unsigned()->default(0);
            $table->integer('user_id')->comment('账号id')->unsigned()->default(0);
            $table->integer('role_id')->comment('角色id')->unsigned()->default(0);
            $table->string('role_name', 32)->comment('角色名称')->default('');
            $table->integer('server_id')->comment('服务器id')->unsigned()->default(0);
            $table->string('server_name', 32)->comment('服务器名称')->default('');
            $table->integer('role_level')->comment('角色等级')->unsigned()->default(0);

            $table->index('create_time');
            $table->index('game_id');
            $table->index('channel');
            $table->index('user_id');
            $table->index('role_id');
            $table->index('server_id');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::connection('mysql_log')->dropIfExists('log_user_role_login');
    }
};
